
const electron = require('electron');
const ipcMain = require('electron').ipcMain;
const portIsOccupied = require('./src/lib/portIsOccupied')
let port = 2000;

ipcMain.on('get-express-port', function(event) {
    event.returnValue = port;
});

const app = electron.app;


portIsOccupied(port)
    .then(_port=>{
        port = _port;
        console.log(_port)
    })



app.on('ready', ()=>{

    let win = new electron.BrowserWindow({
        width: 496,
        height: 483,
        webPreferences: {
            nodeIntegration: true
        },
        frame:true,
        resizable:true,
        icon:'./favicon.ico'
    })
    electron.Menu.setApplicationMenu(null)

    win.loadFile('./src/index.html')
    win.webContents.openDevTools({
        mode:'bottom'
    })
    win.on('closed', () => {
        win = null
    })

})
